Re: audio device on ubuntu
Carl Karsten <[email protected]> Sun, 30 Aug 2009 17:10:02 -0500
| Newsgroups | gmane.comp.video.kino.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Aug 30, 2009 at 3:30 PM, Dan Dennedy<[email protected]> wrote: > On Sun, Aug 30, 2009 at 9:42 AM, Carl Karsten<[email protected]> wrote: >> On Sat, Aug 29, 2009 at 11:29 PM, Dan Dennedy<[email protected]> wrote: >>> On Sat, Aug 29, 2009 at 5:45 PM, Carl Karsten<[email protected]> wrote: >>>> It seams to be playing at 1x. >>> >>> That message is not based on what speed you are playing at; it is >>> based on what speed it was at when you recorded. It could be that the >>> message only appears for a couple of frames and you have some other >>> audio output problem. Do you think you are getting the message for >>> each frame while playing. >> >> yes. played 30 frames, got 30 lines of # no audio > > OK > >>> >>>> It is dv from dvgrab/dvswitch, should be >>>> fine. >> >> Actually, some new dvswitch code was written back in March that >> creates a dv stream from alsa (black video.) There is a chance that >> it isn't quite right. >> >> you mind reviewing some code: >> >> dvsource-alsa calls dv_buffer_set_audio in dif_audio.c >> >> http://svn.debian.org/wsvn/dvswitch/trunk/src/dvsource-alsa.c >> http://svn.debian.org/wsvn/dvswitch/trunk/src/dif_audio.c >> >> void dv_buffer_set_audio(uint8_t * buffer, >> enum dv_sample_rate sample_rate_code, >> unsigned frame_count, const int16_t * samples) >> { >> const struct dv_system * system = dv_buffer_system(buffer); >> >> assert(sample_rate_code >= 0 && sample_rate_code < dv_sample_rate_count); >> assert(frame_count >= system->audio_frame_counts[sample_rate_code].min && >> frame_count <= system->audio_frame_counts[sample_rate_code].max); >> >> bool use_12bit = sample_rate_code == dv_sample_rate_32k; >> unsigned sample_count = frame_count * 2; // stereo >> >> // Each audio block has a 3-byte block id, a 5-byte AAUX >> // pack, and 72 bytes of samples. Audio block 3 in each >> // sequence has an AS (audio source) pack, audio block 4 >> // has an ASC (audio source control) pack, and the other >> // packs seem to be optional. >> static const uint8_t aaux_blank_pack[DIF_PACK_SIZE] = { >> 0xFF, 0xFF, 0xFF, 0xFF, 0xFF >> }; >> uint8_t aaux_as_pack[DIF_PACK_SIZE] = { >> // pack id; 0x50 for AAUX source >> 0x50, >> // bits 0-5: number of audio frames in video frame minus minimum value >> // bit 6: flag "should be 1" >> // bit 7: flag for unlocked audio sampling >> (frame_count - system->audio_frame_counts[sample_rate_code].min) >> | (1 << 6) | (1 << 7), >> // bits 0-3: audio mode >> // bit 4: flag for independent channels >> // bit 5: flag for "lumped" stereo (?) >> // bits 6-7: number of audio channels per block minus 1 >> use_12bit << 6, >> // bits 0-4: system type; 0x0 for DV >> // bit 5: frame rate; 0 for 29.97 fps, 1 for 25 fps >> // bit 6: flag for multi-language audio >> // bit 7: ? >> dv_buffer_system_code(buffer) << 5, >> // bits 0-2: quantisation; 0 for 16-bit LPCM, 1 for 12-bit >> // bits 3-5: sample rate code >> // bit 6: time constant of emphasis; must be 1 >> // bit 7: flag for no emphasis >> use_12bit | (sample_rate_code << 3) | (1 << 6) | (1 << 7) >> }; >> static const uint8_t aaux_asc_pack[DIF_PACK_SIZE] = { >> // pack id; 0x51 for AAUX source control >> 0x51, >> // bits 0-1: emphasis flag and ? >> // bits 2-3: compression level; 0 for once >> // bits 4-5: input type; 1 for digital >> // bits 6-7: copy generation management system; 0 for unrestricted >> (1 << 4), >> // bits 0-2: ? >> // bits 3-5: recording mode; 1 for original (XXX should indicate dub) >> // bit 6: recording end flag, inverted >> // bit 7: recording start flag, inverted >> (1 << 3) | (1 << 6) | (1 << 7), >> // bits 0-6: speed; 0x20 seems to be normal >> // bit 7: direction: 1 for forward >> 0x20 | (1 << 7), > > Here is how libdv interprets this and causes 'no audio' messages: > int dv_is_normal_speed (dv_decoder_t *dv) > { > int normal_speed = TRUE; > > if (dv->std == e_dv_std_iec_61834) { > normal_speed = (dv->audio->aaux_asc.pc3.speed == 0x20); > } else if (dv->std == e_dv_std_smpte_314m) { > if(dv->audio->aaux_as.pc3.system) { > /* PAL */ > normal_speed = (dv->audio->aaux_asc.pc3.speed == 0x64); > } else { > /* NTSC */ > normal_speed = (dv->audio->aaux_asc.pc3.speed == 0x78); > } /* else */ > } > return normal_speed; > > I bet dvsource-alsa.c is signaling this as a smpte stream and not iec. > As can be seen below from libdv, that is determined by the APT field > in some DV header. > > dv->std = ((header->apt) ? e_dv_std_smpte_314m : e_dv_std_iec_61834); > > >From dvsource-alsa.c: > > int apt = (system == &dv_system_625_50) ? 0 : 1; > > Here is how libdv determines system: > > dv->system = (header->dsf || (dv_system_50_fields (dv) == 1)) ? > e_dv_system_625_50 : e_dv_system_525_60; > > dsf field comes from a VAUX header. Here is the core part of > dv_system_50_fields: > > if ((id = dv -> vaux_pack [0x60]) != 0xff) { > if (dv -> vaux_data [id] [2] & 0x20) { > return 1; > } > return 0; > } > > So, you see it is not real simple. Now, we have to sort through > dvsource-alsa.c:dv_buffer_fill_dummy() to figure out what is wrong. > > Ya know what? I am kind of resenting the fact that myself and others > have put years of work into libdv, and Roman put years into FFmpeg's > DV. There's two solid implementations that could have been reused. But > no, Ben had to go and reinvent the wheel. I don't want to look into > the finer details of DV again at this time. I already spent enough > time doing that. I no longer maintain Kino and libdv. Ask Ben to fix > it. No prob. I totally understand. To Ben's defense his day job is writing ethernet card drivers, and the video thing is a hobby, so that he doesn't know you already did it, bla bla... but like I said... I understand. and I appreciate what you have done. -- Carl K ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july