if(!recording) return;
if(p == NULL) return;
QByteArray *pp = new QByteArray(p->data(), p->size());
- //AGAR_DebugLog(AGAR_LOG_DEBUG, "Movie: Enqueue video data %d bytes", p->size());
+ AGAR_DebugLog(AGAR_LOG_DEBUG, "Movie: Enqueue video data %d bytes", p->size());
video_data_queue.enqueue(pp);
//video_width_queue.enqueue(width);
//video_height_queue.enqueue(height);
return true;
}
-void MOVIE_SAVER::enqueue_audio(QByteArray *p)
+void MOVIE_SAVER::enqueue_audio(int16_t *p, int size)
{
#if defined(USE_MOVIE_SAVER)
if(!recording) return;
if(p == NULL) return;
- QByteArray *pp = new QByteArray(p->data(), p->size());
- //AGAR_DebugLog(AGAR_LOG_DEBUG, "Movie: Enqueue audio data %d bytes", p->size());
+ QByteArray *pp = new QByteArray((const char *)p, size);
+ //AGAR_DebugLog(AGAR_LOG_DEBUG, "Movie: Enqueue audio data %d bytes", size);
audio_data_queue.enqueue(pp);
#endif
}
public slots:
void run();
void enqueue_video(QByteArray *p, int width, int height);
- void enqueue_audio(QByteArray *p);
+ void enqueue_audio(int16_t *p, int size);
void do_close();
bool do_open(QString filename, int);
void do_set_width(int width);
return false;
}
- /* init signal generator */
- ost->t = 0;
- ost->tincr = 2 * M_PI * 110.0 / c->sample_rate;
- /* increment frequency by 110 Hz per second */
- ost->tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;
-
if (c->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
nb_samples = 10000;
else
}
for (i = 0; i < ost->st->codec->channels; i++) {
q[offset++] = audio_frame_buf[audio_offset++];
- audio_remain--;
+ audio_remain -= sizeof(int16_t);
if(audio_remain <= 0) {
audio_offset = 0;
break;
/* convert samples from native format to destination codec format, using the resampler */
/* compute destination number of samples */
dst_nb_samples = av_rescale_rnd(swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples,
- c->sample_rate, c->sample_rate, AV_ROUND_UP);
+ c->sample_rate, 48000, AV_ROUND_UP);
av_assert0(dst_nb_samples == frame->nb_samples);
/* when we pass a frame to the encoder, it may keep a reference to it
}
/* convert to destination format */
ret = swr_convert(ost->swr_ctx,
- ost->frame->data, dst_nb_samples,
- (const uint8_t **)frame->data, frame->nb_samples);
- if (ret < 0) {
- AGAR_DebugLog(AGAR_LOG_INFO, "Error while converting\n");
- return -1;
- }
- frame = ost->frame;
-
+ ost->frame->data, dst_nb_samples,
+ (const uint8_t **)frame->data, frame->nb_samples);
+ if (ret < 0) {
+ AGAR_DebugLog(AGAR_LOG_INFO, "Error while converting\n");
+ return -1;
+ }
+ frame = ost->frame;
+
frame->pts = av_rescale_q(ost->samples_count, (AVRational){1, c->sample_rate}, c->time_base);
ost->samples_count += dst_nb_samples;
totalAudioFrame++;
case AVMEDIA_TYPE_AUDIO:
c->sample_fmt = (*codec)->sample_fmts ?
(*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
- c->bit_rate = 64000;
- c->sample_rate = 44100;
+ c->bit_rate = 128000;
+ c->sample_rate = 48000;
if ((*codec)->supported_samplerates) {
c->sample_rate = (*codec)->supported_samplerates[0];
for (i = 0; (*codec)->supported_samplerates[i]; i++) {
- if ((*codec)->supported_samplerates[i] == 44100)
- c->sample_rate = 44100;
+ if ((*codec)->supported_samplerates[i] == 48000)
+ c->sample_rate = 48000;
}
}
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
connect(emu->get_osd(), SIGNAL(sig_movie_set_width(int)), hSaveMovieThread, SLOT(do_set_width(int)));
connect(emu->get_osd(), SIGNAL(sig_movie_set_height(int)), hSaveMovieThread, SLOT(do_set_height(int)));
- connect(emu->get_osd(), SIGNAL(sig_enqueue_audio(QByteArray *)), hSaveMovieThread, SLOT(enqueue_audio(QByteArray *)));
+ connect(emu->get_osd(), SIGNAL(sig_enqueue_audio(int16_t*, int)), hSaveMovieThread, SLOT(enqueue_audio(int16_t *, int)));
connect(emu->get_osd(), SIGNAL(sig_enqueue_video(QByteArray *, int, int)), hSaveMovieThread, SLOT(enqueue_video(QByteArray *, int, int)));
connect(this, SIGNAL(sig_quit_movie_thread()), hSaveMovieThread, SLOT(do_exit()));
int sig_put_string_debugger(QString);
int sig_console_input_string(QString);
int sig_enqueue_video(QByteArray *data, int width, int height);
- int sig_enqueue_audio(QByteArray *data);
+ int sig_enqueue_audio(int16_t *data, int size);
int sig_movie_set_width(int);
int sig_movie_set_height(int);
int sig_debugger_finished();
int length = samples * sizeof(int16_t) * 2; // stereo
if(now_record_video) {
if(sound_samples > rec_sound_buffer_ptr) {
- QByteArray *p = new QByteArray((const char *)(sound_buffer + rec_sound_buffer_ptr * 2), length);
- emit sig_enqueue_audio(p);
+ //QByteArray *p = new QByteArray((const char *)(sound_buffer + rec_sound_buffer_ptr * 2), length);
+ //emit sig_enqueue_audio(p);
+ emit sig_enqueue_audio((int16_t *)(&(sound_buffer[rec_sound_buffer_ptr * 2])), length);
}
}
// record sound