[matroska] r1261 - trunk/foo_input_matroska
[email protected] Fri, 13 Oct 2006 00:50:21 +0400 (MSD)
| Newsgroups | gmane.comp.multimedia.matroska.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: ayana
Date: 2006-10-13 00:50:18 +0400 (Fri, 13 Oct 2006)
New Revision: 1261
Modified:
trunk/foo_input_matroska/foo_input_matroska.cpp
Log:
fix: illegal abort when playing on network drive
Modified: trunk/foo_input_matroska/foo_input_matroska.cpp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/foo_input_matroska/foo_input_matroska.cpp 2006-07-25 09:43:32 U=
TC (rev 1260)
+++ trunk/foo_input_matroska/foo_input_matroska.cpp 2006-10-12 20:50:18 U=
TC (rev 1261)
@@ -62,7 +62,7 @@
=20
class input_matroska
{
- MatroskaAudioParser *m_parser;
+ matroska_parser_ptr m_parser;
service_ptr_t<packet_decoder> m_decoder;
t_input_open_reason m_reason;
=20
@@ -98,7 +98,7 @@
input_matroska()
{
hprintf(L"Matroska: input_matroska()\n");
- m_parser =3D NULL;
+ //m_parser =3D NULL;
m_decoder =3D NULL;
m_TrackNo =3D 0;
m_skip_samples =3D 0;
@@ -115,12 +115,12 @@
m_vbr_update_interval =3D 0;
m_position =3D 0;
m_length =3D 0;
-
}
=20
~input_matroska()
{
hprintf(L"Matroska: ~input_matroska()\n");
+ hprintf(L"--destruction-- position=3D%d frame=3D0x%p\n", m_posit=
ion, m_frame);
cleanup();
}
=20
@@ -139,16 +139,15 @@
=20
m_file =3D p_filehint;
input_open_file_helper(m_file, p_path, p_reason, p_abort);
- m_reason =3D p_reason;
+ m_reason =3D p_reason;
=20
- m_parser =3D new MatroskaAudioParser(m_file, p_abort);
+ m_parser =3D matroska_parser_ptr(new MatroskaAudioParser(m_file,=
p_abort));
+ if (m_parser->Parse(!(m_reason & input_open_decode))) {
+ console::error("Matroska: Invalid Matroska file.");
+ cleanup();
+ throw exception_io_unsupported_format();
+ }
=20
- if (m_parser->Parse(!(m_reason & input_open_decode))) {
- console::error("Matroska: Invalid Matroska file.");
- cleanup();
- throw exception_io_unsupported_format();
- }
-
m_TrackNo =3D m_parser->GetFirstAudioTrack();
if (m_TrackNo =3D=3D -1) {
console::error("Matroska: no decodable streams found.");
@@ -170,6 +169,7 @@
t_uint32 get_subsong(unsigned p_index) {
hprintf(L"Matroska: get_subsong() chapters=3D %d, p_index=3D%d\n", m_p=
arser->GetChapters().size(), p_index);
return p_index;
+ /*
if(m_parser->GetChapters().size() > 0)
{
int tr =3D 0;
@@ -184,6 +184,7 @@
m_parser->SetCurrentTrack(m_TrackNo);
return p_index;
}
+ */
}
=20
void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_=
abort) {
@@ -224,7 +225,6 @@
hprintf(L"Matroska: decode_initialize() =3D %d\n", p_subsong);
set_current_track(p_subsong);
initialize_decorder(p_abort);
- m_decoder->reset_after_seek();
// The timecode scale in Matroska is in milliseconds, but foobar deals=
in seconds
m_timescale =3D m_parser->GetTimecodeScale() * 1000;
m_length =3D duration_to_samples(m_parser->GetDuration());
@@ -268,9 +268,18 @@
=20
if (m_frame_remaining=3D=3D0 || m_frame=3D=3D0)
{
- if (m_frame!=3D0)
+ if (m_frame!=3D0) {
delete m_frame;
- m_frame =3D m_parser->ReadSingleFrame();
+ m_frame =3D NULL;
+ }
+ hprintf(L"Matroska: decode_run() start ReadSingleFrame()=
\n");
+ try {
+ m_frame =3D m_parser->ReadSingleFrame();
+ } catch (const pfc::exception & e) {
+ hprintf(L"Matroska: ReadSingleFrame(): exception=3D%=
s\n", e.what());
+ cleanup();
+ return false;
+ }
if (m_frame=3D=3D0) {
hprintf(L"Matroska: decode_run() return false: m_fra=
me=3D0\n");
return false;
@@ -278,11 +287,13 @@
m_frame_remaining =3D m_frame->dataBuffer.size();
if (m_frame_remaining =3D=3D 0) {
hprintf(L"Matroska: decode_run() return false: m_fra=
me_remaining=3D0\n");
+ cleanup();
return false;
}
}
=20
{
+ hprintf(L"Matroska: decode_run() buffer set\n");
unsigned ptr =3D m_frame->dataBuffer.size() - (m_frame_remaining--);
//buffer =3D (unsigned char*)&m_frame->dataBuffer.at(ptr)[0];
buffer_size =3D m_frame->dataBuffer.at(ptr).size();
@@ -292,6 +303,7 @@
=09
m_tempchunk.reset();
try {
+ hprintf(L"Matroska: decode_run() start decode()\n");
m_decoder->decode(m_buffer.get_ptr(), buffer_size, m_tempchunk, p_ab=
ort);
if (m_tempchunk.is_empty() && m_frame->add_id > 0) {
m_decoder->decode(&m_frame->additional_data_buffer.a=
t(0), m_frame->additional_data_buffer.size(), m_tempchunk, p_abort);
@@ -436,7 +448,7 @@
=20
m_skip_samples =3D (unsigned)(time_to_skip * m_expected_sample_rate + =
0.5) + max_frame_dependency_samples;
m_frame_remaining =3D 0;
- =09
+ m_decoder->reset_after_seek();
//console::info(uStringPrintf("skip samples: %u",m_skip_samples));
}
=20
@@ -477,7 +489,6 @@
=20
void retag_set_info(t_uint32 p_subsong,const file_info & p_info,abort_c=
allback & p_abort) {
hprintf(L"Matroska: retag_set_info()\n");
- unsigned rv =3D 1;
=20
if (m_parser =3D=3D NULL) throw exception_io_unsupported_format();
=09
@@ -488,8 +499,6 @@
m_parser->SetSubSong(p_subsong);
m_parser->SetTags(p_info);
}
-
- //return !rv ? SET_INFO_SUCCESS : SET_INFO_FAILURE;
}
=20
void retag_commit(abort_callback & p_abort) {
@@ -532,21 +541,23 @@
if (m_frame)
{
delete m_frame;
- m_frame =3D 0;
+ m_frame =3D NULL;
}
+ /*
if (m_parser !=3D NULL) {
delete m_parser;
m_parser =3D NULL;
}
+ */
}
int64 duration_to_samples(double val)
{
- return static_cast<int64>(val * (double)m_expected_sample_rate + 0.5);
+ return audio_math::time_to_samples(val, m_expected_sample_rate);
}
=20
double samples_to_duration(int64 val)
{
- return static_cast<double>(val) / static_cast<double>(m_expected_sampl=
e_rate);
+ return audio_math::samples_to_time(val, m_expected_sample_rate);
}
=20
void set_current_track(unsigned int p_index) {
@@ -579,10 +590,11 @@
setup.sample_rate_output =3D (unsigned)currentTrack.samplesOutputPerS=
ec;
setup.channels =3D (unsigned)currentTrack.channels;
setup.codec_private_size =3D currentTrack.codecPrivate.size();
- if (setup.codec_private_size)
+ if (setup.codec_private_size) {
setup.codec_private =3D ¤tTrack.codecPrivate.at(0);
- else
+ } else {
setup.codec_private =3D NULL;
+ }
=20
packet_decoder::g_open(m_decoder, p_decode, packet_decoder::owner_mat=
roska, 0, &setup, sizeof(setup), p_abort);
if (m_decoder =3D=3D NULL)
@@ -603,7 +615,6 @@
delete m_frame;
m_frame =3D NULL;
}
- m_decoder->reset_after_seek();
// The timecode scale in Matroska is in milliseconds, but foobar deal=
s in seconds
m_timescale =3D m_parser->GetTimecodeScale() * 1000;
m_length =3D duration_to_samples(m_parser->GetDuration());
@@ -616,7 +627,7 @@
if (m_frame !=3D NULL) {
unsigned int buffer_size =3D m_frame->dataBuffer.at(0).size();
m_buffer.set_size(buffer_size);
- m_buffer.set_data_fromptr(&m_frame->dataBuffer.at(0)[0], buffer_size=
);
+ m_buffer.set_data_fromptr(&m_frame->dataBuffer.at(0).at(0), buffer_s=
ize);
m_decoder->analyze_first_frame(m_buffer.get_ptr(), buffer_size, p_ab=
ort);
}
}
@@ -630,7 +641,7 @@
#define INPUT_MATROSKA_NAME "Matroska Plugin (/arch:SSE)"
#else
#ifdef _DEBUG
-#define INPUT_MATROSKA_NAME "Matroska Plugin (debug)"
+#define INPUT_MATROSKA_NAME "Matroska Plugin (debug) build. "__DATE__" "=
__TIME__
#else
#define INPUT_MATROSKA_NAME "Matroska Plugin"
#endif
@@ -647,7 +658,7 @@
=20
DECLARE_COMPONENT_VERSION(
INPUT_MATROSKA_NAME,
- "0.9.1.2",
+ "0.9.2.0",
version
);
=20